from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 导入键盘操作类
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
# 最大化浏览器窗口
driver.maximize_window()
url = 'file:///C:/Users/TEACHER/Desktop/NSD2405/html/registerA.html'
driver.get(url)

username = driver.find_element(By.CSS_SELECTOR, '#userA')
# 输入用户名admin1，执行退格键
username.send_keys('admin1')
sleep(3)
username.send_keys(Keys.BACKSPACE)
# 执行Ctrl+a
sleep(3)
username.send_keys(Keys.CONTROL, 'a')
# 执行ctrl+c，复制用户名
sleep(3)
username.send_keys(Keys.CONTROL, 'c')
# 定位密码框，执行ctrl+v，粘贴用户名
password = driver.find_element(By.CSS_SELECTOR, '#passwordA')
password.send_keys(Keys.CONTROL, 'v')

sleep(3)
driver.quit()